<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>20210902124邵文杰</title>
	<script src="vue.js"></script>
	<script src="vuex.js"></script>
</head>
<body>	
<div id="app"></div>	
<script>
  const store = new Vuex.Store({
      state: {
        count: 1
      },
      mutations: {
        increment: state => state.count++,
        decrement: state => state.count--,
      }
    })
    const vm=new Vue({
      el: '#app',
      computed: {
        count () {
           return store.state.count
        }
      },
      
      template: `
        <div>
          <input type="button" value="-" @click="decrement">
          <span>{{ count }}</span>
          <input type="button" value="+" @click="increment">
        </div>
        `,
      
      methods: {
        increment () {
          store.commit('increment')
        },
        decrement () {
          store.commit('decrement')
        },    
      }
    })
</script>
</body>
</html>
